package com.yujinglin.OriginDes;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class OriginDesMapper extends Mapper<LongWritable, Text, NullWritable, Text> {

    private Text outKey = new Text();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();
        String[] info = line.split(",");

        if (info.length >= 19 && !info[7].isEmpty()&& !info[8].isEmpty()) {

            String org_des="无数据";

           try{
               org_des =info[7]+"-"+info[8];
           }catch (Exception e){
               e.printStackTrace();
           }

            outKey.set(org_des); // 设置输出的key为距离分类


            context.write(NullWritable.get(),outKey); // 输出到context，每个记录计数为1

        }

    }
}